package cn.yj.core.business.service;

import cn.yj.annotation.pagehelper.page.Page;
import cn.yj.cgs.dba.entity.Comment;
import cn.yj.cgs.dba.entity.vo.CommentVo;
import cn.yj.cgs.dba.mapper.CommentMapper;
import cn.yj.common.Enums;
import cn.yj.params.check.annotation.Require;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author 永健
 * @since 2021-06-12 22:06
 */
@Service
public class CommentService extends ServiceImpl<CommentMapper, Comment> {

    public Page<CommentVo> pageList(@Require Map<String, Object> params, @Require Page<CommentVo> page) {
        baseMapper.findList(params, page);
        return page;
    }

    public boolean deleteByNo(@Require String commentNo) {
        return baseMapper.delete(new UpdateWrapper<Comment>().lambda().eq(Comment::getCommentNo, commentNo)) > Enums.Common.ZERO;
    }
}
